Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement locking service #15

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Implement locking service #15

wants to merge 6 commits into from

Conversation

gunarp
Copy link
Contributor

@gunarp gunarp commented May 26, 2022

Why make this change?

Our current locking system is always-preemptable, which is fine for our use case but isn't ideal as it means the driver has to be pretty careful with the way they launch scripts, as running some scripts over others might get us into an undefined state.

What changed?

Added new classes LockServer and LockClient, which uses a ros service to implement a mutex which also gives signals to enable control from the UI via the topic /ui/enablement

Also cleaned up the directories in robot_module and modified some of the imports to make them more consistent with other areas of the codebase.

How was it tested?

Tested LockServer class by running lock_service_server.py and sending messages using rosservice.

Also created a test file showing how to use LockClient, example_lock_client.py, and verified that it can be executed (assuming nothing's holding the lock already).

Also double checked that test.py is still runnable after making changes to the imports.

@gunarp gunarp requested review from Anemnox and wang-4 May 26, 2022 08:47
@@ -0,0 +1,27 @@
@startuml Locking Service Sequence Diagram
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PUML is a diagram generator we use at Microsoft, it's free and is a nice way to create pictures from text.

You can generate the diagram by copying this into the bottom of the plant uml website or downloading a local viewer (there's a vs code extension called PlantUml by Jebbs that has some instructions on that)

Also here's a link to the image


# use exponential backoff to try again without flooding network
while not lock_acquired:
rospy.loginfo("Couldn't acquire the lock, trying again")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing to a debug message instead, this will pop up whenever a node is waiting on the lock every once in a while.

Copy link
Contributor

@Anemnox Anemnox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to run me through how to implement this into RobotModule. :')

Copy link
Contributor

@Anemnox Anemnox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually lets make sure to implement the ui before pulling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants